package com.caipiao.crawler.zhongjiangRule;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.caipiao.crawler.model.LotteryNumber;

import java.util.*;

/**
 * 中奖规则
 */
public class ZhongJiangRule {

    /**
     * 大乐透中奖规则
     * @param ticketNumber 选择号码
     * @param prizeNumber 中奖号码
     * @return
     */
    public static Map daletouRule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        String[] prizeNumberArray = prizeNumber.split("-");
        String[] qianquArray = prizeNumberArray[0].split(" ");
        String[] houquArray = prizeNumberArray[1].split(" ");
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        JSONObject detailObj = (JSONObject) detailArray.get(0);
        JSONArray detailsArray = detailObj.getJSONArray("details");
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            String ticketInfo = ticketJson.getString("tickinfo");
            System.out.println(ticketInfo);
            String[] ticketNumberArray = ticketInfo.split("\\+");
            String[] ticketQianquArray = ticketNumberArray[0].split(",");
            String[] ticketHouquArray = ticketNumberArray[1].split(",");
            int countQianqu = countTwoArraySame(qianquArray,ticketQianquArray);
            int countHouqu = countTwoArraySame(houquArray,ticketHouquArray);
            if(countQianqu==5&&countHouqu==2){
                //一等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailsArray.get(0); //一等奖开奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","一等奖"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else if(countQianqu==5&&countHouqu==1){
                //二等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject secondDetails= (JSONObject) detailsArray.get(2); //二等奖开奖详情
                float secondMoney = Float.parseFloat(secondDetails.getString("money").replaceAll(",","")); //二等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","二等奖"); //中奖情况
                prizeMap.put("money",secondDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += secondMoney;  //中奖金额
            }else if(countQianqu==5||(countQianqu==4&&countHouqu==2)){
                //三等奖

                is_prize = 1; //已中奖
                //开奖详情
                JSONObject thirdDetails= (JSONObject) detailsArray.get(4); //三等奖开奖详情
                float thirdMoney =Float.parseFloat(thirdDetails.getString("money").replaceAll(",","")); //三等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","三等奖"); //中奖情况
                prizeMap.put("money",thirdDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += thirdMoney;  //中奖金额
            }else if((countQianqu==4&&countHouqu==1)||(countQianqu==3&&countHouqu==2)){
                //四等奖

                is_prize = 1; //已中奖
                //开奖详情
                JSONObject fourDetails= (JSONObject) detailsArray.get(6); //四等奖开奖详情
                float fourMoney = Float.parseFloat(fourDetails.getString("money").replaceAll(",","")); //四等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","四等奖"); //中奖情况
                prizeMap.put("money",fourDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += fourMoney;  //中奖金额
            }else if(countQianqu==4||(countQianqu==3&&countHouqu==1)||(countQianqu==2&&countHouqu==2)){
                //五等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject fiveDetails= (JSONObject) detailsArray.get(8); //五等奖开奖详情
                float fiveMoney = Float.parseFloat(fiveDetails.getString("money").replaceAll(",","")); //五等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","五等奖"); //中奖情况
                prizeMap.put("money",fiveDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += fiveMoney;  //中奖金额
            }else if(countQianqu==3||(countQianqu==1&&countHouqu==2)||(countQianqu==2&&countHouqu==1)||countHouqu==2){
                //六等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject sixDetails= (JSONObject) detailsArray.get(10); //六等奖开奖详情
                float sixMoney = Float.parseFloat(sixDetails.getString("money").replaceAll(",","")); //六等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","六等奖"); //中奖情况
                prizeMap.put("money",sixDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += sixMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    public static Map qixingcaiRule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        prizeNumber = prizeNumber.replaceAll(" ",""); //中奖号码
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        JSONObject detailObj = (JSONObject) detailArray.get(0);
        JSONArray detailsArray = detailObj.getJSONArray("details");
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            String ticketInfo = ticketJson.getString("tickinfo");
            System.out.println(ticketInfo);
            ticketInfo = ticketInfo.replaceAll(" ",""); //购彩号码
            if(ticketInfo.equals(prizeNumber)){
                //一等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailsArray.get(0); //一等奖开奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","一等奖"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else if(ticketInfo.substring(0,6).equals(prizeNumber.substring(0,6))
                    ||ticketInfo.substring(1,7).equals(prizeNumber.substring(1,7))){
                //二等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject secondDetails= (JSONObject) detailsArray.get(1); //二等奖开奖详情
                float secondMoney = Float.parseFloat(secondDetails.getString("money").replaceAll(",","")); //二等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","二等奖"); //中奖情况
                prizeMap.put("money",secondDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += secondMoney;  //中奖金额
            }else if(ticketInfo.substring(0,5).equals(prizeNumber.substring(0,5))
                    ||ticketInfo.substring(1,6).equals(prizeNumber.substring(1,6))
                    ||ticketInfo.substring(2,7).equals(prizeNumber.substring(2,7))){
                //三等奖

                is_prize = 1; //已中奖
                //开奖详情
                JSONObject thirdDetails= (JSONObject) detailsArray.get(2); //三等奖开奖详情
                float thirdMoney =Float.parseFloat(thirdDetails.getString("money").replaceAll(",","")); //三等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","三等奖"); //中奖情况
                prizeMap.put("money",thirdDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += thirdMoney;  //中奖金额
            }else if(ticketInfo.substring(0,4).equals(prizeNumber.substring(0,4))
                    ||ticketInfo.substring(1,5).equals(prizeNumber.substring(1,5))
                    ||ticketInfo.substring(2,6).equals(prizeNumber.substring(2,6))
                    ||ticketInfo.substring(3,7).equals(prizeNumber.substring(3,7))){
                //四等奖

                is_prize = 1; //已中奖
                //开奖详情
                JSONObject fourDetails= (JSONObject) detailsArray.get(3); //四等奖开奖详情
                float fourMoney = Float.parseFloat(fourDetails.getString("money").replaceAll(",","")); //四等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","四等奖"); //中奖情况
                prizeMap.put("money",fourDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += fourMoney;  //中奖金额
            }else if(ticketInfo.substring(0,3).equals(prizeNumber.substring(0,3))
                    ||ticketInfo.substring(1,4).equals(prizeNumber.substring(1,4))
                    ||ticketInfo.substring(2,5).equals(prizeNumber.substring(2,5))
                    ||ticketInfo.substring(3,6).equals(prizeNumber.substring(3,6))
                    ||ticketInfo.substring(4,7).equals(prizeNumber.substring(4,7))){
                //五等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject fiveDetails= (JSONObject) detailsArray.get(4); //五等奖开奖详情
                float fiveMoney = Float.parseFloat(fiveDetails.getString("money").replaceAll(",","")); //五等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","五等奖"); //中奖情况
                prizeMap.put("money",fiveDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += fiveMoney;  //中奖金额
            }else if(ticketInfo.substring(0,2).equals(prizeNumber.substring(0,2))
                    ||ticketInfo.substring(1,3).equals(prizeNumber.substring(1,3))
                    ||ticketInfo.substring(2,4).equals(prizeNumber.substring(2,4))
                    ||ticketInfo.substring(3,5).equals(prizeNumber.substring(3,5))
                    ||ticketInfo.substring(4,6).equals(prizeNumber.substring(4,6))
                    ||ticketInfo.substring(5,7).equals(prizeNumber.substring(5,7))){
                //六等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject sixDetails= (JSONObject) detailsArray.get(5); //六等奖开奖详情
                float sixMoney = Float.parseFloat(sixDetails.getString("money").replaceAll(",","")); //六等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","六等奖"); //中奖情况
                prizeMap.put("money",sixDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += sixMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    public static Map pailie3Rule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        prizeNumber = prizeNumber.replaceAll(" ",""); //中奖号码
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            String ticketInfo = ticketJson.getString("tickinfo");
            System.out.println(ticketInfo);
            ticketInfo = ticketInfo.replaceAll(" ",""); //购彩号码
            if(ticketInfo.equals(prizeNumber)){
                //直选投注
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailArray.get(0); //直选开奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","直选投注"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else if((prizeNumber.charAt(0)==prizeNumber.charAt(1)
                    ||prizeNumber.charAt(0)==prizeNumber.charAt(2)
                    ||prizeNumber.charAt(1)==prizeNumber.charAt(2))
                    &&countTwoCharArraySame(prizeNumber.toCharArray(),ticketInfo.toCharArray())==3){
                //组选3
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject secondDetails= (JSONObject) detailArray.get(1);
                float secondMoney = Float.parseFloat(secondDetails.getString("money").replaceAll(",","")); //二等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","组选3"); //中奖情况
                prizeMap.put("money",secondDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += secondMoney;  //中奖金额
            }else if(countTwoCharArraySame(prizeNumber.toCharArray(),ticketInfo.toCharArray())==3){
                //组选6

                is_prize = 1; //已中奖
                //开奖详情
                JSONObject thirdDetails= (JSONObject) detailArray.get(2);
                float thirdMoney =Float.parseFloat(thirdDetails.getString("money").replaceAll(",","")); //三等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","组选6"); //中奖情况
                prizeMap.put("money",thirdDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += thirdMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    public static Map pailie5Rule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        prizeNumber = prizeNumber.replaceAll(" ",""); //中奖号码
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            String ticketInfo = ticketJson.getString("tickinfo");
            System.out.println(ticketInfo);
            ticketInfo = ticketInfo.replaceAll(" ",""); //购彩号码
            if(ticketInfo.equals(prizeNumber)){
                //直选投注
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailArray.get(0); //直选开奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","直选投注"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    public static Map shengfuchangRule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        prizeNumber = prizeNumber.replaceAll(" ",""); //中奖号码
        Map<String,String> prizeNumberMap = new LinkedHashMap<String,String>(); //开奖结果
        for(int i=1;i<prizeNumber.length()+1;i++){
            if(i<10) {
                prizeNumberMap.put("0"+i,String.valueOf(prizeNumber.charAt(i-1)));
            }else{
                prizeNumberMap.put(String.valueOf(i),String.valueOf(prizeNumber.charAt(i-1)));
            }
        }
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            Map<String,String> ticketInfoMap = new LinkedHashMap<String,String>(); //开奖结果
            for(int j =1;j<15;j++) {
                if(j<10) {
                    ticketInfoMap.put("0"+j,ticketJson.getString("0" + j));
                }else{
                    ticketInfoMap.put(String.valueOf(j),ticketJson.getString(String.valueOf(j)));
                }
            }
            if(countTwoStringNoSame(prizeNumberMap,ticketInfoMap)==14){
                //一等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailArray.get(0); //一等奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","一等奖"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else if(countTwoStringNoSame(prizeNumberMap,ticketInfoMap)==13){
                //二等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject secondDetails= (JSONObject) detailArray.get(1); //二等奖详情
                float firstMoney = Float.parseFloat(secondDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","二等奖"); //中奖情况
                prizeMap.put("money",secondDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    /**
     * 任选9中奖
     * @param ticketNumber
     * @param prizeNumber
     * @param lotteryNumber
     * @param multiple
     * @return
     */
    public static Map renxuan9Rule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        prizeNumber = prizeNumber.replaceAll(" ",""); //中奖号码
        Map<String,String> prizeNumberMap = new LinkedHashMap<String,String>(); //开奖结果
        for(int i=1;i<prizeNumber.length()+1;i++){
            if(i<10) {
                prizeNumberMap.put("0"+i,String.valueOf(prizeNumber.charAt(i-1)));
            }else{
                prizeNumberMap.put(String.valueOf(i),String.valueOf(prizeNumber.charAt(i-1)));
            }
        }
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            Map<String,String> ticketInfoMap = new LinkedHashMap<String,String>(); //开奖结果
            for(int j =1;j<15;j++) {
                if(j<10) {
                    ticketInfoMap.put("0"+j,ticketJson.getString("0" + j));
                }else{
                    ticketInfoMap.put(String.valueOf(j),ticketJson.getString(String.valueOf(j)));
                }
            }
            if(countTwoStringNoSame(prizeNumberMap,ticketInfoMap)==9){
                //任选9
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailArray.get(2); //任选9详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","任选9"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    /**
     * 进球彩中奖规则
     * @param ticketNumber
     * @param prizeNumber
     * @param lotteryNumber
     * @param multiple
     * @return
     */
    public static Map jinqiucaiRule(String ticketNumber, String prizeNumber, LotteryNumber lotteryNumber,int multiple){
        Map map = new LinkedHashMap();
        String[] prizeArr = prizeNumber.replaceAll("＋","").split(" ");
        Map<String,String> prizeNumberMap = new LinkedHashMap<String,String>(); //开奖结果
        for(int i=1;i<prizeArr.length+1;i++){
                prizeNumberMap.put("0"+i,prizeArr[i-1]);
        }
        JSONArray array = JSON.parseArray(ticketNumber);
        float prize_amount = 0;
        List prize_detail = new ArrayList();
        int is_prize = 0;
        String detali = lotteryNumber.getPrize_detail();
        JSONArray detailArray =  JSON.parseArray(detali);
        for(int i=0;i<array.size();i++){
            JSONObject ticketJson = (JSONObject) array.get(i);
            Map<String,String> ticketInfoMap = new LinkedHashMap<String,String>(); //开奖结果
            for(int j =1;j<9;j++) {
                    ticketInfoMap.put("0"+j,ticketJson.getString("0" + j));
            }
            if(countTwoStringNoSame(prizeNumberMap,ticketInfoMap)==8){
                //一等奖
                is_prize = 1; //已中奖
                //开奖详情
                JSONObject firstDetails= (JSONObject) detailArray.get(0); //一等奖详情
                float firstMoney = Float.parseFloat(firstDetails.getString("money").replaceAll(",","")); //一等奖开奖金额
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","一等奖"); //中奖情况
                prizeMap.put("money",firstDetails.getString("money")); //每注奖金
                prize_detail.add(prizeMap);
                prize_amount += firstMoney;  //中奖金额
            }else{
                Map prizeMap = new LinkedHashMap();
                prizeMap.put("prize","未中奖"); //中奖情况
                prizeMap.put("money",""); //每注奖金
                prize_detail.add(prizeMap);
            }
        }
        map.put("is_prize",is_prize); //订单是否中奖
        map.put("prize_amount",prize_amount*multiple); //订单中奖金额
        map.put("prize_detail", JSON.toJSONString(prize_detail));
        return map;
    }

    /**
     * 判断两个数组重复的次数
     * @param array1
     * @param array2
     * @return
     */
    public static int countTwoArraySame(String[] array1,String[] array2){
        List<String> listA = new ArrayList<String>();
        for(int i=0;i<array1.length;i++) {
            listA.add(array1[i]);
        }
        List<String> listB =  new ArrayList<String>();
        for(int i=0;i<array2.length;i++) {
            listB.add(array2[i]);
        }
        listA.retainAll(listB);
        return listA.size();
    }

    public static int countTwoCharArraySame(char[] array1,char[] array2){
        List<Character> listA = new ArrayList<Character>();
        for(int i=0;i<array1.length;i++) {
            listA.add(array1[i]);
        }
        List<Character> listB =  new ArrayList<Character>();
        for(int i=0;i<array2.length;i++) {
            listB.add(array2[i]);
        }
        listA.retainAll(listB);
        return listA.size();
    }

    /**
     * 两个字符串不同的数的数量
     * @return
     */
    public static int countTwoStringNoSame(Map<String,String> prizeNumber,Map<String,String> ticketNumber){
        String ticketInfo="";
        String prizeInfo="";
        int count = 0;
        for(int i=1;i<15;i++){
            if(i<10) {
                 ticketInfo = ticketNumber.get("0"+i);
                prizeInfo = prizeNumber.get("0"+i);
            }else{
                 ticketInfo = ticketNumber.get(String.valueOf(i));
                 prizeInfo = prizeNumber.get(String.valueOf(i));
            }
            if(ticketInfo!=null&&prizeInfo.equals(ticketInfo)){
                count++;
            }
        }
        return count;
    }
}
